package Rangel.common.world.entity;


import rescuecore2.standard.entities.Blockade;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;


public class RangelBlockade {//封装的路障类
    private Polygon blockade;//用于表示形状
    private Blockade parent;//底层的路障类
    private RangelRoad position;//路障处于的道路
    private List<RangelEdge> blockedEdges;//构成路障的边缘
    private int repairCost;//清理的消耗

    public RangelBlockade(RangelRoad road, Blockade blockade, Polygon polygon) {
        initialize(road, blockade, polygon);
    }

    private void initialize(RangelRoad road, Blockade blockade, Polygon polygon) {
        this.parent = blockade;
        this.blockade = polygon;
        blockedEdges = new ArrayList<>();
        position = road;
        repairCost = blockade.getRepairCost();
    }


    public Polygon getPolygon() {
        return blockade;
    }

    public List<RangelEdge> getBlockedEdges() {
        return blockedEdges;
    }

    public void addBlockedEdges(RangelEdge RangelEdge) {
        if (!blockedEdges.contains(RangelEdge))
            blockedEdges.add(RangelEdge);
    }

    public RangelRoad getPosition() {
        return position;
    }

    public Blockade getParent() {
        return parent;
    }

    public int getRepairCost() {
        return repairCost;
    }

    @Override
    public boolean equals(Object obj) {
        RangelBlockade otherBlockade;
        if (obj instanceof RangelBlockade) {
            otherBlockade = (RangelBlockade) obj;
            return getPolygon().equals(otherBlockade.getPolygon());
        }
        return false;
    }
}
